{% extends "default.html" %}

{% block content %}
<div class="title">
	Historial del Cliente - {{ request.client }}
</div>
<div class="content">
	<div class="font_title">Estado de Cuenta</div>
	<table class="data_table">
		<tr>
			<th>Compras realizadas</th>
			<td>{{ request.sales.count }} compras</td>
		</tr>
		<tr>
			<th>Gastado en compras realizadas</th>
			<td>{{ request.expended }} Bs</td>
		</tr>
		<tr>
			<th>Deuda</th>
			<td>{{ request.debt }} Bs</td>
		</tr>
	</table>
	<div class="font_title">Pagos realizados</div>
	<table class="data_table">
		<tr>
			<th>Ver detalle de Pagos</th>
			<td><a href="/staff/clients/{{ request.client.id }}/payment/">Ver</a></td>
		</tr>
	</table>
	<div class="font_title">Resumen de ventas</div>
	<table class="data_table">
		<tr>
			<th>Fecha</th>
			<th>Factura</th>
			<th>Credito / Contado</th>
			<th>Pagado / Es deuda</th>
			<th>Acciones</th>
		</tr>
		{% for v in request.sales %}
			<tr>
				<td>{{ v.made }}</td>
				<td>{{ v.bill_number }}</td>
				<td>
					{% if v.payment_method %}
						Contado
					{% else %}
						Cr&eacute;dito
					{% endif %}
				</td>
				<td>
					{% if v.payment_method %}
						Pagado
					{% else %}
						{% if v.payed %}
							Pagado
						{% else %}
							<span class="red_debtor">Es deuda</span>
						{% endif %}
					{% endif %}
				</td>
				<td><a href="javascript:show_sale({{ v.id }})">Ver Reporte</a></td>
			</tr>
		{% endfor %}
	</table>
</div>
{% endblock %}